package cn.smile.feign;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;

@FeignClient(name = "wechat-client", url = "https://api.weixin.qq.com")
public interface WeChatFeignClient {

    /**
     * 上传文件到微信公众号平台
     *
     * @param accessToken 微信请求的Token
     * @param file        文件资源
     * @return 处理结果
     */
    @PostMapping(value = "/cgi-bin/material/add_material?access_token={accessToken}&type=image", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    String uploadMaterial(@PathVariable(value = "accessToken") String accessToken, @RequestPart("media") MultipartFile file);
}
